% Takes two vectors of equal lenth repressenting variables and calculates
% their correlation. 1 indicates a perfect positive correlation, 0
% indicates no correlation, and -1 indicates a perfect negative correlation
function r = correlation(x,y)
xbar = mean(x);
ybar = mean(y);
r = sum((x-xbar).*(y-ybar))/(sqrt(sum((x-xbar).^2))*sqrt(sum((y-ybar).^2)));
